<!DOCTYPE html>
<!--suppress HtmlUnknownAttribute -->
<html lang="zh-Hans-CN" xmlns:sec="http://www.thymeleaf.org/extras/spring-security" xmlns:th="http://www.thymeleaf.org">
<head>
  <th:block th:include="include :: header"/>
  <title>井列表汇总导出</title>
</head>
<body class="pear-container">
<div class="layui-card">
  <div class="layui-card-body">
    <table id="well-info-table" lay-filter="well-info-table"></table>

    <script id="well-code-toolbar" type="text/html">
      <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="word">
        <i class="layui-icon layui-icon-download-circle"></i>
        详情导出
      </button>
      <button class="pear-btn pear-btn-md" lay-event="excel">
        <i class="layui-icon layui-icon-export"></i>
        汇总导出
      </button>
    </script>

    <script id="well-info-bar" type="text/html">
      <button sec:authorize="hasAnyAuthority('ROLE_ADMIN','well:info:detail')"
              class="pear-btn pear-btn-primary pear-btn-sm" lay-event="detail"><i
        class="pear-icon pear-icon-image-text"></i>
      </button>
    </script>
  </div>
</div>

<script id="well-status" type="text/html">
  {{#if (d.status == 'NotAccepted') { }}
  <span>审核不通过（打回修改）</span>
  {{# }else if(d.status == 'Approved'){ }}
  <span>审核通过</span>
  {{# }else{ }}
  <span>已上报（审核中）</span>
  {{# } }}
</script>

<th:block th:include="include :: footer"/>
<script>
  layui.use(['table', 'form', 'jquery', 'dictionary'], function () {
    let table = layui.table;

    let prefix = "/well/info/";

    let cols = [
      [
        {type: 'checkbox'},
        {field: 'id', title: '废弃井编号'},
        {field: 'name', title: '废弃井名称'},
        {field: 'originCode', title: '原始编号'},
        {field: 'digTime', title: '建井时间'},
        {field: 'company', title: '井所属单位'},
        {field: 'status', title: '上报状态', templet: '#well-status'},
        {title: '操作', toolbar: '#well-info-bar', align: 'center', width: 160}
      ]
    ]

    table.render({
      elem: '#well-info-table',
      url: prefix + 'page',
      page: true,
      cols: cols,
      skin: 'line',
      toolbar: '#well-code-toolbar',
      defaultToolbar: [{
        title: '刷新',
        layEvent: 'refresh',
        icon: 'layui-icon-refresh',
      }, 'filter']
    });

    table.on('tool(well-info-table)', function (obj) {
      if (obj.event === 'detail') {
        window.detail(obj);
      }
    });

    table.on('toolbar(well-info-table)', function (obj) {
      if (obj.event === 'excel') {
        window.open("excel")
      } else if (obj.event === 'word') {
        window.open("word")
      } else if (obj.event === 'refresh') {
        window.refresh();
      }
    });

    window.detail = function (obj) {
      layer.open({
        type: 2,
        title: '井信息详情',
        shade: 0.1,
        area: ['550px', '500px'],
        content: prefix + 'detail?id=' + obj.data['id']
      });
    }

    window.refresh = function () {
      table.reload('well-info-table');
    }
  })
</script>
</body>
</html>
